package com.bailong.administrator.ausedcar.http;



import com.bailong.administrator.ausedcar.bean.BuyCarsBean;


import com.bailong.administrator.ausedcar.bean.DetailBean;

import com.bailong.administrator.ausedcar.bean.HomeHotBean;






import com.bailong.administrator.ausedcar.bean.HomeLikeBean;
import com.bailong.administrator.ausedcar.bean.HomeShowBean;
import com.bailong.administrator.ausedcar.config.UrlConfig;
import com.google.gson.Gson;

import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2016/9/6.
 */
public class HttpUtils {
    private HttpUtils(){};
    private static HttpUtils utile= new HttpUtils();
    public static HttpUtils newInstance(){
        return utile;
    }
    public void loadHomeLikeBean(Callback<HomeLikeBean> callback, Map<String,String> map){


        Retrofit retrofit = new Retrofit.Builder().baseUrl(UrlConfig.BASEURL).addConverterFactory(GsonConverterFactory.create(new Gson())).build();
        InterRetrofit retrofitInter = retrofit.create(InterRetrofit.class);
        Call<HomeLikeBean> leftBeanCall = retrofitInter.loadHomeLikeBean(map);

        leftBeanCall.enqueue(callback);
    }
    public void loadHomeLikeBeanC(Callback<HomeLikeBean> callback, Map<String,String> map){


        Retrofit retrofit = new Retrofit.Builder().baseUrl(UrlConfig.BASEURL).addConverterFactory(GsonConverterFactory.create(new Gson())).build();
        InterRetrofit retrofitInter = retrofit.create(InterRetrofit.class);
        Call<HomeLikeBean> leftBeanCall = retrofitInter.loadHomeShowBeanC(map);

        leftBeanCall.enqueue(callback);
    }


    public void loadBuyCars(Callback<BuyCarsBean> callback, Map<String,String> map){
        Retrofit retrofit = new Retrofit.Builder().baseUrl(UrlConfig.BASEURL).addConverterFactory(GsonConverterFactory.create(new Gson())).build();
        InterRetrofit retrofitInter = retrofit.create(InterRetrofit.class);
        Call<BuyCarsBean> leftBeanCall = retrofitInter.loadBuyCarsBean(map);
        leftBeanCall.enqueue(callback);
    }


    public void loadHomeHotBean(Callback<HomeHotBean> callback, Map<String,String> map){


        Retrofit retrofit = new Retrofit.Builder().baseUrl(UrlConfig.BASEURL).addConverterFactory(GsonConverterFactory.create(new Gson())).build();
        InterRetrofit retrofitInter = retrofit.create(InterRetrofit.class);
        Call<HomeHotBean> leftBeanCall = retrofitInter.loadHomeHotBean(map);
        leftBeanCall.enqueue(callback);
    }


    public void loadHomeShowBean(Callback<HomeShowBean> callback, Map<String,String> map){


        Retrofit retrofit = new Retrofit.Builder().baseUrl(UrlConfig.BASEURL).addConverterFactory(GsonConverterFactory.create(new Gson())).build();
        InterRetrofit retrofitInter = retrofit.create(InterRetrofit.class);
        Call<HomeShowBean> leftBeanCall = retrofitInter.loadHomeShowBean(map);
        leftBeanCall.enqueue(callback);
    }

    public void loadDetailBean(Callback<DetailBean> callback, Map<String,String> map){


        Retrofit retrofit = new Retrofit.Builder().baseUrl(UrlConfig.BASEURL).addConverterFactory(GsonConverterFactory.create(new Gson())).build();
        InterRetrofit retrofitInter = retrofit.create(InterRetrofit.class);
        Call<DetailBean> leftBeanCall = retrofitInter.loadDetailBean(map);

        leftBeanCall.enqueue(callback);
    }


}
